<?php

class mysql {

  private $db;
  
  public function __construct($host, $username, $password, $database) {
    //$this->write("Generating from DB: $id ($host $database)");
    //if (!file_exists($this->appPath.'data/'.$id)) { mkdir($this->appPath.'data/'.$id, 0755); }
    //if (!file_exists($this->appPath.'data/'.$id.'/mysql')) { mkdir($this->appPath.'data/'.$id.'/mysql', 0755); }
    
    $this->db = new mysqli($host,$username,$password,$database);
  }

  
  public function getTables() {

    $retval = array();
    $result = $this->db->query("SHOW TABLES");
    while($row = $result->fetch_array()) {
      $retval[] = $row[0];
    }
    return $retval;
  }

  public function getFields($table) {
    
    $retval = array();
    $result = $this->db->query("DESCRIBE $table");
    while($row = $result->fetch_array()) {
      $retval[] = $row[0];
    }
    return $retval;
  }

}